<?php

/**
 * openPaymentAccount	开通支付账户跳转	接口
 * Date: 2016/11/24 14:34
 */

function testResponse(){

    $config = $GLOBALS['config'];
    $user = $GLOBALS['user'];


    $objReq = new \yijipay\message\request\WalletRequest();


    //请求公共部分
    $objReq->setReturnUrl(getReturnUrl());
    $objReq->setNotifyUrl(getNotifyUrl());
    //partnerId默认yijipay\config.php中已经配置
    //$objReq->setPartnerId($config['partnerId']); 
    $objReq->setMerchOrderNo("T" . genOrderNo());
    $objReq->setOrderNo("RID".genOrderNo());
    //signType默认MD5
    $objReq->setSignType("RSA");
    //$objReq->setContext("");


    //必填参数
    $objReq->setUserId($user['seller_uid_yiji']);
    //objReq->setUserId($user['buyer_uid_yiji']);

    //选填参数
    $objReq->setTermnalType("PC");

    echo "================request: preSignStr：";
    echo "<br/>". \yijipay\SignHelper::getPreSignStr($objReq);

    //构建请求
    $client = new \yijipay\YijiPayClient($config);
    

    //方式1：重定向到易极付页面
//    $html = $client->pageExecute($objReq);
//    echo $html;
//    exit;

    //方式2: 获取重定向URL
    $response = $client->execute($objReq);
    $resp = json_decode($response);
    if($client->verify($response) && $resp->success){
        //================================
        // 此处填写创建成功的代码
        //================================

    }else{
        //================================
        // 此处填写创建成功的代码
        //====
        throw new Exception($resp->resultMessage);
    }

    exit;
}

